class MultiCounter < Pan::Component
  def initialize counters
    @colors = ["red","green","blue","yellow","white"]
    @counters = []
    counters.times {add_counter}
  end

  def add_counter
    color = WebColor.new
    @counters << Counter.new(color)
  end

  def counters
    @counters.size
  end

  def del_counter
    @counters.pop
  end

  def total
    @counters.inject(0){|acc, counter| acc + counter.value}
  end
  
  def render_on(html)
    @counters.each{|ea| ea.render_on(html)}
  end
end
